<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算属性和侦听器</title>
    <script src="../vue.js"></script>
</head>
<body>

<div id="root">
姓: <input type="text" v-model="firstName">
名: <input type="text" v-model="lastName">
    <div>{{fName}}</div>
    <div>{{count}}</div>
</div>


</body>
<script>
    new Vue({
        el:"#root",
        data:{
            firstName:'',
            lastName:'',
            count:0,
        },
        /*计算方法*/
        computed:{
            fName:function () {
                return this.firstName+' '+this.lastName;
            }
        },
        /*侦听器*/
        watch:{
            fName:function () {
                this.count++;
            }
        }


    })

</script>
</html>